﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace GuRenFang.Web.Management
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("elmah.axd");
            routes.IgnoreRoute("{*alljs}", new { alljs = @".*\.js?" });
            routes.IgnoreRoute("{*allashx}", new { allashx = @".*\.ashx?" });
            routes.IgnoreRoute("{*allhtml}", new { allhtml = @".*\.htm?" });
            routes.IgnoreRoute("{*allcss}", new { allcss = @".*\.css?" });
            routes.IgnoreRoute("{*allimages}", new { allimages = @".*\.ico?|.*\.jpg?|.*\.png?|.*\.gif?" });

            routes.MapRoute(
                name: "Login",
                url: "Login",
                defaults: new { controller = "DefaultAdmin", action = "Login", id = UrlParameter.Optional }
            );
            routes.MapRoute(
                name: "LogOff",
                url: "Logoff",
                defaults: new { controller = "DefaultAdmin", action = "LogOff", id = UrlParameter.Optional }
            );
            routes.MapRoute(
                name: "DefaultPage",
                url: "Default",
                defaults: new { controller = "DefaultAdmin", action = "Default", id = UrlParameter.Optional }
            );
            routes.MapRoute(
                name: "DefaultRule",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "DefaultAdmin", action = "Default", id = UrlParameter.Optional }
            );

            routes.MapRoute(
             "404-PageNotFound",
             "{*catchall}",
             new { controller = "Home", action = "Error" }
           );
        }
    }
}